//
//  AboutDCMViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/6/30.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "AboutDCMViewController.h"
#import "WebviewProgressLine.h"


@interface AboutDCMViewController ()<UIWebViewDelegate>

@property (nonatomic,strong) WebviewProgressLine  *progressLine;

@end

@implementation AboutDCMViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self setupNavBar];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    webView.scalesPageToFit = YES;
    webView.delegate = self;
    
    NSURL *url = [NSURL URLWithString:@"http://www.dcmfx.com/"];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    
    [self.view addSubview:webView];
    
    
}


- (void)setupNavBar{
    
    self.title = @"关于我们";
    
    UIButton * backButton = [[UIButton alloc] init];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToAccountView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
    
    
    self.progressLine = [[WebviewProgressLine alloc] initWithFrame:CGRectMake(0, 1 * SCREENH6, SCREEN_WIDTH, 3 * SCREENH6)];
    
    self.progressLine.hidden = NO;
    self.progressLine.lineColor = [UIColor redColor];
    [self.view bringSubviewToFront:self.progressLine];
    [self.view addSubview:self.progressLine];
}


-(void)webViewDidStartLoad:(UIWebView *)webView{
    
    [self.progressLine startLoadingAnimation];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    [self.progressLine endLoadingAnimation];
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    
    [self.progressLine endLoadingAnimation];
}



- (void)backToAccountView{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
